/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308;

import cse308.entities.Courseinfo;
import cse308.entities.Degreeprogram;
import java.util.Collection;
import java.util.logging.Logger;
import javax.persistence.EntityManager;

/**
 *
 * @author Aaron
 */
public class AssociateRemoveOrAdd {

    private GeneralEntity makeChangeTo;
    private GeneralEntity change;
    private final static Logger LOG = Logger.getLogger(GUIUtilityClass.class.getName());

    public AssociateRemoveOrAdd(GeneralEntity makeChangeTo, GeneralEntity change) {
        this.makeChangeTo = makeChangeTo;
        this.change = change;
    }

    public void makeChange(boolean add, EntityManager em) {
        if (add) {
            makeChangeTo.testAddClass(change);
            em.persist(em.merge(makeChangeTo));
        } else {
            makeChangeTo.removeClass(change);
            em.persist(em.merge(makeChangeTo));
        }
    }
}
